﻿@model Jb.Web.ViewModels.UtilityModels.ListConfig
@using Jb.Common.Extensions;
@using Jb.Web.Utility;
@using Jb.Web.ViewModels;
@{
    String _Keyword = Jb.Common.DB.NullHandler.GetString(ViewData[AppConstants.ViewDataKeys.SEARCH_KEY]);
    String pageTitle = "Search Resumes";
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    
    Jb.Web.ViewModels.UtilityModels.PagerConfig _PagerConfig = Model.Pager;
    ///Define Pager URL Format
    _PagerConfig.UrlFormat = "/Private/Resume/Search?key=" + _Keyword + "&pageNo={0}";
    if (_Keyword.IsNullOrEmpty())
    {
        ViewBag.ShowMessage = false;
    }
    ViewData[AppConstants.ViewDataKeys.CALCULATE_OCCURANCE] = true;
    ///Getis
    if (Model.DataSource == null){
        Model.DataSource = new System.Data.DataTable();
    }
    ViewData[AppConstants.ViewDataKeys.SELECTED_MENU] = EmployerMenu.SearchResume;
    bool _CanDownloadResume = PackageInfo.CanDownloadResume;
    int _DisplayableResultCount = Model.DataSource != null && _CanDownloadResume ? Model.DataSource.Rows.Count : 0;
}
<div class="jb-page-heading">
    <h1>@pageTitle</h1>
    <div>
        @if(_Keyword.IsNullOrEmpty()){
            <text>Enter your keyword in the following text box and click Search.</text>
        }
        else {
        <text>List of matched resume(s) for your given search keyword.</text>
        }
    </div>
</div>

@{String autoClass = _Keyword.IsNullOrEmpty() || _DisplayableResultCount == 0 ? String.Empty : "auto";}
<div class="jb-page-content @(autoClass)">
    @using (Html.BeginForm("search", "resume", FormMethod.Post, new { id="frmSearch", style = "margin:0px;"}))
    {
    <div class="span6">
        <div class="input-append">
            <input id="txtKeyword" name="keyword" type="text" maxlength="100" value="@_Keyword" placeholder="Enter your keyword" />
            <button class="btn btn-primary" type="submit"><i class="icon-search icon-white"></i> Search</button>            
        </div>        
    </div>
    <div class="span2">        
        <button class="btn" type="button" id="btnSearchTips" onclick="ShowSearchTips();"><i class="icon-hand-right"></i> Search Tips</button>  
    </div>
    <div class="clearfix"></div>
    }
    @if (!_CanDownloadResume) {
        @Html.WarningMessageBox("Please subscribe to a <a href='/Package/List'>package here</a> to download resume.")
    }
</div>

@if (_CanDownloadResume)
{
<div id="divSearchResult">
    @Html.Partial("_ResumeList", Model.DataSource)
    @if (_PagerConfig != null && !_Keyword.IsNullOrEmpty())
    {
        autoClass = _PagerConfig.TotalRecord > 0 ? "auto" : String.Empty;        
        <div class="jb-page-content @(autoClass)">
        @Html.Partial("_Pager", _PagerConfig)
        </div>
    }
</div>
}

<div id="divSearchTipsDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="divPhotoEditModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
        <h4 id="myModalLabel">Resume Search Tips</h4>
    </div>
    <div class="modal-body jb-inline-label">            
        <div id="divModalMesssage">
            <a href="/">@ConfigReader.SiteName</a>'s search engine supports several techniques of search. 
            You can specify them in your search keyword. They are preety simple and you can try few of them. 
            Suppose you are looking for a Web Developer, then you can format your keywords in following ways:
            <ul class="search-tips">
                <li>
                    If you want a exact match in your search result then sorrund your keyword with a <b>double quote</b> (")<br />
                    <b>Example:</b> "Web Developer"
                </li>
                <li>
                    If you want to match all of your keywords, then you can use <b>and</b> operator.<br />
                    <b>Example:</b> Web AND Developer
                </li>
                <li>
                    If you want to match few of your keywords, then you can try <b>or</b> operator.<br />
                    <b>Example:</b> Web OR Developer
                </li>
                <li>
                    Or you can simply enter your search criteria about what you are looking for and 
                    @ConfigReader.SiteName's search engine will intelligently show matching resumes.
                </li>
            </ul>
        </div>
    </div>
    <div class="modal-footer">        
        <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-off"></i> Close</button>
    </div>
</div>

@section PageHeadSection
{
    <style type="text/css">
        #txtKeyword{width:100%; font-size:19px;}        
        .jb-job{padding: 0px 0px 10px 0px; }                
    </style>
}

@section JavaScriptPlaceHolder{
<script language="javascript" type="text/javascript">
    function ShowSearchTips() {
        $('#divSearchTipsDialog').modal({ show: true });
    }
</script>
}
